home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12704 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  44 lines

  1. Path: iway.fr!diagram!usenet
  2. From: Jean-Dominique BOISSE <jdbo@diagram.fr>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: help with strcmp
  5. Date: Tue, 02 Apr 1996 13:06:19 -0800
  6. Organization: DIAGRAM
  7. Message-ID: <316196CB.1125@diagram.fr>
  8. References: <4jpiek$lp6@blaze.cs.jhu.edu>
  9. NNTP-Posting-Host: 100.3.13.155
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. John E. Davis wrote:
  16. > ...
  17. > void main(int argc, char *argv[])
  18. > {
  19. > char            buf[20], data[40], *buff, *arg, *fp;
  20. > FILE            *handle, *dest;
  21. > int             n;
  22. > handle = fopen(argv[1], "r");
  23. > if(dest = fopen( "dbuild.out", "w")) setup(dest);
  24. > while(!feof(handle)) {
  25. >         n = 0;
  26. >         fp = fgets(data, 40, handle);
  27. >         if ( strcasecmp(fp, "<action>\n") == 0)  /* the coredump is here */
  28.  
  29.     I think that you must use strncasecmp instead of strcasecmp, like this
  30.  
  31.         strncasecmp(fp,"<action>\n",40)
  32.  
  33.     This function will only read 40 characters from fp for the test.
  34.  
  35.     You can also put a '\0' at the very end of fp (fp[40])  and still use     
  36.     strcasecmp, but read only 39 chars from handle.
  37.  
  38.  
  39.                 Jean-Dominique BOISSE
  40.  
  41.                 (jdbo@diagram.fr)
  42.